﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Gqq.CodeFirst.Palace;

namespace Gqq.CodeFirst.ProcessPalace
{
    public class Part10 : PartBase
    {
        public static void TestRawSql()
        {
            var sql = "select * from unicorn";
            var result = db.Unicorns.SqlQuery(sql);

            foreach (var unicorn in result.ToList())
            {
                Console.WriteLine(unicorn.Name);
            }
        }

        public static int TestRawSqls()
        {
            var sql = "select id as Id,name as Name from princess";
            var result = db.Database.SqlQuery<Person>(sql);
            foreach (var princess in result.ToList())
            {
                Console.Write(princess.Id + "          ");
                Console.WriteLine(princess.Name);
            }
            return result.Count();
        }
    }

    internal class Person
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int Test { get; set; }
    }
}
